#ifndef DependencyDecoder_H
#define DependencyDecoder_H
#include"DependencyPipe.h"
#include"HashMap.h"

class DependencyDecoder{
public:
	DependencyPipe* pipe;
	
	DependencyDecoder(DependencyPipe* pipe);
	
	virtual ~DependencyDecoder();
	
	vector<pair<FeatureVector*, string*> >* decodeProjective(DependencyInstance* inst,
		vector<vector<vector<double> > > &probs, vector<vector<vector<vector<double> > > > &nt_probs, int K);
	
	vector<pair<FeatureVector*, string*> >* decodeNonProjective(DependencyInstance* inst,
		vector<vector<vector<FeatureVector> > > &fvs, vector<vector<vector<double> > > &probs,
		vector<vector<vector<vector<FeatureVector> > > > &nt_fvs,
		vector<vector<vector<vector<double> > > > &nt_probs, int K);

protected:
	vector<vector<int> >* getTypes(vector<vector<vector<vector<double> > > > &nt_probs, int len);
	
	int* getKChanges(int* par, double* scoreMatrix, int K, int numWords);
	
	bool* calcChilds(int* par, int numWords);
	
	void chuLiuEdmonds(double* scoreMatrix, bool* curr_nodes,
		int* oldI, int* oldO, bool print, IntHashMap &final_edges,
		IntHashMap* reps, int numWords);
};
#endif
